/*
 * Filename:    WarnResultServiceImpl.java
 * Copyright:   2014 中国平安保险（集团）股份有限公司 版权所有
 * Company:     平安科技养老险及健康险系统开发部
 * Create at:   2014年11月12日
 */
package com.paic.mhis.hcpms.warning.biz.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.paic.mhis.hcpms.warning.biz.service.WarnResultService;
import com.paic.mhis.hcpms.warning.dao.WarnResultDAO;
import com.paic.mhis.hcpms.warning.dto.WarnMonitorDTO;
import com.paic.mhis.hcpms.warning.dto.WarnResultDTO;

@Service("warnResultService")
public class WarnResultServiceImpl implements WarnResultService {
	@Autowired
	private WarnResultDAO warnResultDao;

	@Override
	public int addWarnResult(JSONObject transferJson, Map<String, Object> paramMap) {
		String warnNo = transferJson.get("warnNo").toString();
		String opinion = transferJson.get("opinion").toString();
		String traceStartDate = transferJson.get("traceStartDate").toString();
		String traceEndDate = transferJson.get("traceEndDate").toString();
		if (StringUtils.isNotBlank(warnNo) && StringUtils.isNotBlank(opinion) && StringUtils.isNotBlank(traceStartDate)
				&& StringUtils.isNotBlank(traceEndDate)) {
			paramMap.put("warnNo", warnNo);
			paramMap.put("opinion", opinion);
			paramMap.put("traceStartDate", traceStartDate);
			paramMap.put("traceEndDate", traceEndDate);
			warnResultDao.addWarnResult(paramMap);
			return 1;
		}
		return 0;
	}

	@Override
	public List<WarnMonitorDTO> findWarnMonitor() {
		return warnResultDao.findWarnMonitor();
	}

	@Override
	public List<WarnMonitorDTO> findWarnMonitorRule() {
		return warnResultDao.findWarnMonitorRule();
	}

	@Override
	public WarnResultDTO warningResultQuery(String warnNo) {
		if (StringUtils.isEmpty(warnNo)) {
			return null;
		}
		return warnResultDao.warningResultQuery(warnNo);
	}
}
